﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using Model.EF;

public partial class System_Role_RoleSet : System.Web.UI.Page
{
    public SystemMenu menu = new SystemMenu();
    public SystemRoleMenu rolemenu = new SystemRoleMenu();
    protected string id = "";
    protected string mid = "";
    protected string rid = "";
    public string Query = "";
    public string Add = "";
    public string Update = "";
    public string Del = "";
    protected string rel = "";
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            if (Request.QueryString["mid"] != null)
            {
                rel = Request.QueryString["rel"].ToString();
                IRepository<SystemMenu> MenuRepository = new EntityRepository<SystemMenu>();
                menu = MenuRepository.FindById(int.Parse(Request.QueryString["mid"]));
                rolemenu = menu.SystemRoleMenus.Where(c => c.SystemRoleID == int.Parse(Request.QueryString["rid"])).FirstOrDefault();
                if (rolemenu != null)
                {
                    id = rolemenu.ID.ToString();
                    mid = rolemenu.SystemMenuID.ToString();
                    rid = rolemenu.SystemRoleID.ToString();
                    if (rolemenu.Query)
                    {
                        Query = "checked=\"checked\"";
                    }
                    if (rolemenu.Add)
                    {
                        Add = "checked=\"checked\"";
                    }
                    if (rolemenu.Del)
                    {
                        Del = "checked=\"checked\"";
                    }
                    if (rolemenu.Update)
                    {
                        Update = "checked=\"checked\"";
                    }
                }
                else
                {
                    mid = Request.QueryString["mid"].ToString();
                    rid = Request.QueryString["rid"].ToString();
                }
                
            }
        }
    }
}